<template>
  <div>
    <h3 class="h3">获取教师所属学生信息</h3>
    <teacher-student :datas="datas"></teacher-student>
    <h3 class="h3">获取教师所属课题信息</h3>
    <teacher-choice :choices="choices"></teacher-choice>
    <h3 class="h3">获取教师所属评阅信息</h3>
    <teacher-comment :comment="comment"></teacher-comment>
    <h3 class="h3">获取教师所属课题信息</h3>
    <teacher-topic :topic="topic"></teacher-topic>
    <h3 class="h3">获取全部课题信息</h3>
    <teacher-alltopic :alltopic="alltopic"></teacher-alltopic>
    <h3 class="h3">获取学生签到信息</h3>
    <student-sign :sign="sign"></student-sign>
  </div>
</template>

<script>
import TeacherStudent from './components/teacher-student.vue'
import TeacherChoice from './components/teacher-choice.vue'
import TeacherComment from './components/teacher-comment.vue'
import TeacherTopic from './components/teacher-topic.vue'
import TeacherAlltopic from './components/teacher-alltopic.vue'
import StudentSign from './components/student-sign.vue'
import axios from 'axios'
export default {
  name: 'Table',
  components: {
    TeacherStudent,
    TeacherChoice,
    TeacherComment,
    TeacherTopic,
    TeacherAlltopic,
    StudentSign
  },
  data () {
    return {
      datas: [],
      choices: [],
      comment: [],
      topic: [],
      alltopic: [],
      sign: []
    }
  },
  methods: {
    getMessage () {
      this.axios.get('/api/teacher/15070841/student')
        .then(this.getStudentInfo)
    },
    getChoice () {
      this.axios.get('/api/teacher/15070841/choice')
        .then(this.getChoiceInfo)
    },
    getComment () {
      this.axios.get('/api/teacher/15070842/comment')
        .then(this.getCommentInfo)
    },
    getTopic () {
      this.axios.get('/api/teacher/15070842/topic')
        .then(this.getTopictInfo)
    },
    getAlltopic () {
       this.axios.get('/api/topic')
        .then(this.getAlltopictInfo)
    },
    getSign () {
      this.axios.get('/api/student/1507084143/sign')
        .then(this.getSignInfo)
    },
    getSignInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.sign = data
    },
    getAlltopictInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.alltopic = data
    },
    getTopictInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.topic = data
    },
    getCommentInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.comment = data
    },
    getChoiceInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.choices = data
    },
    getStudentInfo (res) {
      const data = res.data.data
      data.forEach(value => {
        for (let item in value) {
          if (value[item] === null) {
            value[item] = "-"
          }
        }
      })
      this.datas = data
    }
  },
  mounted () {
    this.getMessage()
    this.getChoice()
    this.getComment()
    this.getTopic()
    this.getAlltopic(),
    this.getSign()
  }
}
</script>

<style lang="stylus" scoped>
  .h3
    width: 100%
    text-align: center
</style>
